( function( global, factory ) {

	"use strict";

	if ( typeof module === "object" && typeof module.exports === "object" ) {

	
		module.exports = global.document ?
			factory( global, true ) :
			function( w ) {
				if ( !w.document ) {
					throw new Error( "Arrayutil requires a window with a document" );
				}
				return factory( w );
			};
	} else {
		factory( global );
	}

// Pass this if window is not defined yet
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {

	var ArrayUtil={
    
				    remove:function(arr, val ){
				        for (var i = arr.length - 1; i >= 0; i--) {
				            if(arr[i] == val )arr.splice(i, 1);
				        }
				        return arr ; 
				    },
				    removes:function(arr,vals){
				        for (var i = vals.length - 1; i >= 0; i--) {
				           arr = this.remove(arr,vals[i]);
				        }
				        return arr ; 
				    },
				    arrayRemove:function (arr,key,obj) {
				            var isArr = Array.isArray(key);
				            for(var i = arr.length - 1;  i >=0; i --){
				                if(isArr){

				                    var f = true;
				                    for(var j = 0;  j < key.length ; j ++){

				                        if(arr[i][key[j]] != obj[key[j]]){
				                            f = false;
				                            break;
				                        }
				                    }
				                    if(f)arr.splice(i,1);

				                }else{

				                    if(arr[i][key] == obj[key])arr.splice(i,1);

				                }
				                
				            }
				            return arr; 
				    },
				    arrayRemoveAll:function (arr,key,objs) {
				            
				            for(var i = 0 ; i <objs.length ; i++){
				                arr = this.arrayRemove(arr,key,objs[i]);
				            }
				            return arr; 
				    },
				    arrayRemoveForKeyValue:function(arr ,key,value ){

				        for(var i = arr.length -1 ; i >=0 ; i --){
				            if(arr[i][key] == value)arr.splice(i,1);
				        }
				        return arr;
				    },
				    arrayRemoveForKeys:function (arr, key1 , obj ,key2 ){


				            for(var i = arr.length -1 ; i >=0 ; i--){

				                if(arr[i][key1] == obj[key2])arr.splice(i,1);
				            }
				            return arr ; 

				    },
				    arrayRemoveAllForKeys:function (arr,key1,objs,key2 ){

				            for(var i = 0 ; i <objs.length ; i ++){
				               arr = this.arrayRemoveForKeys(arr,key1,objs[i],key2);
				            }
				            return arr;
				    },
				    arrayAddForKeys:function (arr,key1,obj,key2 ){

				            for(var i = 0 ; i<arr.length ; i ++){
				                if(arr[i][key1] == obj[key2])return arr;
				            }
				            arr.push(obj);
				            return arr;
				    },
				    arrayAddAllForKeys:function (arr,key1,objs,key2 ){

				            for(var i = 0 ; i <objs.length ; i ++){
				               arr = this.arrayAddForKeys(arr,key1,objs[i],key2);
				            }
				            return arr;
				    },
				    arrayAdd:function (arr ,key ,obj ){
				            var isArr = Array.isArray(key);
				            for(var i= 0 ; i <arr.length ;i++){
				                if(isArr){
				                    var f = true  ;
				                    for(var j = 0 ; j <key.length ; j ++){

				                        if(arr[i][key[j]] != obj[key[j]]){
				                            f = false;
				                            break;
				                        }
				                    }
				                      if(f)return arr;

				                }else{
				                    if(arr[i][key] == obj[key]) {
				                        return arr ;
				                    }
				                }
				            }
				            arr.push(obj);
				            return arr ; 
				    },
				   arrayAddAll:function (arr,key,objs){

				            for(var i = 0 ; i<objs.length ; i ++){
				                arr = this.arrayAdd(arr,key,objs[i]);
				            }
				            return arr;
				    },

				    arrayGetByKeyValue:function(arr,key,value){
				        var t = [];
				        for(var i = 0 ; i<arr.length ; i ++){
				            if(arr[i][key] == value){
				                t.push(arr[i]);
				            }
				        }
				        return t ;
				    }




	}





	var _ArrayUtil = window.ArrayUtil;




// Expose jQuery and $ identifiers, even in AMD
// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566)
	if ( !noGlobal ) {
		window.ArrayUtil = ArrayUtil;
	}


})
